package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.UserCoupon;
import top.tsyz.service.IUserCouponService;

import java.util.List;

/**
 * UserCouponController控制器
 */
@RestController
@RequestMapping("/api/userCoupons")
@Api(tags = "UserCoupon管理接口")
public class UserCouponController {

    @Autowired
    private IUserCouponService iusercouponservice;

    @GetMapping("/list")
    @ApiOperation("获取所有UserCoupon")
    public List<UserCoupon> list() {
        return iusercouponservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取UserCoupon")
    public UserCoupon getById(@PathVariable Long id) {
        return iusercouponservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增UserCoupon")
    public boolean save(@RequestBody UserCoupon usercoupon) {
        return iusercouponservice.save(usercoupon);
    }

    @PutMapping
    @ApiOperation("更新UserCoupon")
    public boolean update(@RequestBody UserCoupon usercoupon) {
        return iusercouponservice.updateById(usercoupon);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除UserCoupon")
    public boolean delete(@PathVariable Long id) {
        return iusercouponservice.removeById(id);
    }
}
